/**
 * 
 * @Title: 账户类型 
 * @Description: TODO
 * @author zzr
 * @date 2018年4月21日 09:05:45
 */

package com.example.houseman.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

public enum AccountTypeEnum {

	DUIGONGZHANGHU("对公账户", 1),
    DUISIZHANGHU("对私账户", 2);

	@JsonValue
    private String name;
	@EnumValue
    private int index;

    private AccountTypeEnum(String name, int index) {
        this.name = name;
        this.index = index;
    }

    // 普通方法
    public static String getName(int index) {
        for (AccountTypeEnum c : AccountTypeEnum.values()) {
            if (c.getIndex() == index) {
                return c.name;
            }
        }
        return null;
    }

    public static Integer getIndex(String name) {
        for (AccountTypeEnum c : AccountTypeEnum.values()) {
            if (c.getName().equals(name)) {
                return c.getIndex();
            }
        }
        return null;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}
